
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>协同办公系统登陆</title>
    <link rel="stylesheet" href="../static/css/bootstrap.css">
    <link rel="stylesheet" href="../static/js/layui/css/layui.css">
    <link rel="stylesheet" href="../static/css/font.css">
    <style>
        #boxes>div{
            margin-left: 5%;
        }
        #left>a{
            margin-top:30px;
            margin-left: 20px;
        }

        #from_block{
            width: 90%;
            margin-top: 20px;
            height: 300px;
            padding-top: 20px;

        }

    </style>
</head>
<body>
<div id="from_block">
    <form method="post" >
        <div class="layui-form-item">
            <label class="layui-form-label login-form"><i class="iconfont" style="color: #0b3b8c">&#xe6b8;</i></label>
            <div class="layui-input-inline login-inline">
                <input type="text" name="username" id="username" lay-verify="required" placeholder="请输入用户的帐号" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label login-form"><i class="iconfont" style="color: #0b3b8c">&#xe6b2;</i></label>
            <div class="layui-input-inline login-inline">
                <input type="password" name="pass" id="pass"  lay-verify="required" placeholder="密码" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="form-actions" style="text-align: center" >
            <button class="btn btn-warning " lay-submit lay-filter="login" style="margin-left: 10%" onclick="login()" type="button">提&nbsp;&nbsp;交</button>
            <button class="btn btn-warning " lay-submit lay-filter="login" style="margin-left: 10%" onclick="reset()"  type="button">继续添加</button>
        </div>
    </form>
</div>
<script src="../static/js/jquery.min.js"></script>
<script src="../static/js/layui/layui.all.js"></script>
<script>


    function login() {
        var user_name = $('input[name="username"]'),
            pass=$('input[name="pass"]');
        if (user_name.val() === '') {
            layer.msg('你的账号还未填写');
            return false;


        }
        else if(pass.val()===""){
            layer.msg("该用户的密码还没填写哦");
            return false;

        }

        else {
            $user = user_name.val();
            $pass=pass.val();
            $.ajax({
                type: 'post',
                cache: 'false',
                url: '../php/user/add_user.php',
                data: {
                    "user": $user,
                    "pass":$pass,
                },
                dataType: 'Json',
                success: function (dat) {
                    layer.msg(dat.message);

                },
                error: function (dat) {
                    layer.msg("添加失败，请检查网络是否正常");
                }


            })


        }
    }


</script>
</body>
</html>